/**
*  \file    test_cfg.h
*
*  \brief   Configuration header for unit test
*
*  \author  Michael J. Hohmann <michael.hohmann@linde-mh.de>
*
*
*/

#ifndef TEST_CFG_H_INCLUDED
#define TEST_CFG_H_INCLUDED

/*================================================[ public includes  ]================================================*/
#include "../cfg/prj.h"
#include "../test/test.h"
#include <stdio.h>
#include <time.h>
#include <windows.h>
/*================================================[ public defines   ]================================================*/

/*================================================[ public datatypes ]================================================*/
/** Test Case Enumerator.
*
*  This enumerator should contain an entry for every test case that will be used.
*/
enum test_case
{
   test_case_generic,
#if 0
   sec_common_use_cases,
      construct_with_invalid_usecase,

   sec_constructor_asserts,

   sec_test_functions_with_nil_obj_prt,
      raise_assert_if_object_pointer_is_nil,
      timekeeper_get_time_nil,
      timekeeper_set_time_nil,
      timekeeper_save_nil,
      timekeeper_measure_nil,

      construct_with_nil_sd_prt,
      construct_with_0_numcnt_assert,

      object_not_altered_by_sd_nil_construct,

      sec_call_constructor_with_unitialized_sd_device,

      sec_call_constructor_with_cleaned_sd_dev,

      construct_with_cleand_values,
      obj_not_altered_after_constructor_call_with_NIL,

      sec_random_start_values,
         initialize_with_random_values,
#endif
   test_case_last /**< This has to be the last entry */
};

/*================================================[ public variables ]================================================*/

/*===============================================[ private datatypes ]================================================*/

/*================================================[ inline functions ]================================================*/

/** Get Time
*   This function should return seconds since 1970.
*   If no timer is available it should return zero.
*
*   \return seconds since 1970-01-01:00:00;00
*/
STATIC_INLINE U32 test_get_time(void)
{
   return time(NIL);
}

/** Get Time
*   This function should return a high resolution timer.
*   If no timer is available it should return zero.
*
*   \return High resolution time
*/
STATIC_INLINE U32 test_get_high_resolution_time(void)
{
   LARGE_INTEGER lpPerformanceCount;
   QueryPerformanceCounter(&lpPerformanceCount);
   return (U32) lpPerformanceCount.QuadPart;  /* default return 0 */
}

/** Ticks per second
*
*  This function should return the number of ticks per second that the macro test_get_time() use as time base.
*  If no timing function is specified for test_get_time() this macro should return U32_CONST(0).
*
*  \return Time base
*/
STATIC_INLINE U32 test_get_ticks_per_second(void)
{
   LARGE_INTEGER lpPerformancefreq;
   QueryPerformanceFrequency(&lpPerformancefreq);
   return (U32) lpPerformancefreq.QuadPart;  /* default return 0 */
}

/** Function to print out test results
*
*  The implemented function should be able to transfer the passed contend to a system where the information
*  can be collected to a test protocol.
*  On a PC-System this is typical a printf to the console.
*  On an embedded it could be a transmission via CAN-Bus.
*
*  \param str Pointer to a null terminated string. This string will be printed.
*/
STATIC_INLINE void test_print( CH const* str )
{
   (void) printf("%s",str);
}

/** Function to print out test result string with length limit
 * 
*  The implemented function should be able to transfer the passed contend to a system where the information
*  can be collected to a test protocol.
*  On a PC-System this is typical a printf to the console.
*  On an embedded it could be a transmission via CAN-Bus.
*
* \param str Pointer to a null terminated string. This string will be printed.
* \param len the length to print.
* 
*/
STATIC_INLINE void test_nprint( CH const* str, int len)
{
   (void) printf("%.*s", len, str);
}

/** Debug location.
*
* If a dedicated use test case should be debugged its a good practice to add a breakpoint to this location.
* This function will be called before test will be executed.
*
* \return The return value will ignored.
*/
STATIC_INLINE BO test_debug_location(void)
{
   /* Dear highly honored developer.
   *  Well consider you next steps and don't overlook the obvious.
   *  Remember the big picture and your beloved.*/
   if( IsDebuggerPresent() )
   {
      asm("int $3"); /* set breakpoint */
   }
   return TRUE; /* go with step into (F5) to the testfunction that failed the last time */
}

/*================================================[ public functions ]================================================*/

/*====================================================================================================================*/

#endif

/***********************************************************************************************************************
*                             Copyright 2017 Linde Material Handling. All rights reserved.                             *
***********************************************************************************************************************/
